<template>
	<view style="background-color: white;">
		<swiper class="swiper" :indicator-dots="indicatorDots" :indicator-active-color="activeColor">
			<swiper-item v-for="(item, index) in bannerArr" :key="item.id">
				<image :src="item.imgSrc" mode="widthFix"></image>
				<view class="box">
					<view class="title"></view>
					<view class="desc">{{item.title}}</view>
				</view>
			</swiper-item>
		</swiper>
		
	</view>
</template>

<script>
	export default {
		data() {
			return {
				indicatorDots: true,
				bannerArr: [
				],
				activeColor: "red",
				articleArr: [],
			};
		},
		created() {
			// 从云数据库里取数据
			uniCloud.callFunction({
				name: "getNews",
				data: {
					name: "news"
				}
			}).then(res => {
				let {
					articleArr,
					bannerArr
				} = res.result.data[0];
				this.articleArr = articleArr;
				this.bannerArr = bannerArr;
				//console.log(this.articleArr);
			})
		}
	}
</script>

<style lang="scss">
	@import url('/iconfonts/iconfont.css');

	swiper {
		background-color: white;
		position: relative;
		width: 90%;
		margin-left: 5%;
		margin-top: 20rpx;
		border-radius: 30rpx;
		overflow: hidden;
		swiper-item {
			position: relative;
			background-color: white;
			image {
				width: 100vw;
				filter: brightness(0.9);
			}

			.box {
				position: absolute;
				left: 0;
				bottom: 40rpx;
				padding: 0 4%;
				padding: 10rpx;

				.title {
					background: rgba(0, 0, 0, 0.2);
					color: #ffc81f;

					.iconfont {
						margin-right: 10rpx;
						margin-left: 10rpx;
					}

					font-size: 20rpx;
					display: inline-block;
				}

				.desc {
					margin-left: 10rpx;
					color: #fff;
					display: -webkit-box;
					-webkit-box-orient: vertical;
					-webkit-line-clamp: 3;
					overflow: hidden;
				}
			}
		}

	}

	.list {
		
		.li {
			margin-top: 10rpx;
			position: relative;

			image {
				width: 100%;
				filter: brightness(0.8);
			}

			.box {
				position: absolute;
				left: 0;
				bottom: 40rpx;
				padding: 0 4%;
				padding: 10rpx;

				.title {
					background: rgba(0, 0, 0, 0.2);
					color: #ffc81f;
					margin-left: 10rpx;

					.iconfont {
						margin-right: 10rpx;
						margin-left: 10rpx;
					}

					font-size: 20rpx;
					display: inline-block;
				}

				.desc {
					margin-left: 10rpx;
					color: #fff;
					display: -webkit-box;
					-webkit-box-orient: vertical;
					-webkit-line-clamp: 3;
					overflow: hidden;
				}

				.love {
					color: #fff;
					font-size: 24rpx;

					.iconfont {
						margin-left: 10rpx;
					}
				}
			}
		}
	}
</style>
